import React from "react"
import { connect } from "react-redux"
import { Button } from 'antd';
class ReactX0202 extends React.Component {
    constructor(props) {
        super(props);
        let { INCREMENT, DECREMENT } = this.props;
        this.INCREMENT = INCREMENT
        this.DECREMENT = DECREMENT
    }

    render() {
        return (

            <div>
                <h2>{this.props.number}</h2>
                <div className="margin_top_sm">
                    <Button onClick={() => { this.INCREMENT() }} className="margin_right_sm" type="primary">增加</Button>
                    <Button onClick={() => { this.DECREMENT() }} type="primary">减少</Button>
                </div>
            </div>

        )
    }
}
//读数据的方法
const mapStateToprops = (state) => {
    return {
        number: state
    }
}
const setStateToprops = (dispatch) => {
    return {
        INCREMENT: () => { dispatch({ type: 'INCREMENT' }) },
        DECREMENT: () => { dispatch({ type: 'DECREMENT' }) }
    }
}
//按照顺序
export default connect(mapStateToprops, setStateToprops)(ReactX0202) 